<template>
  <div class="qushuikou-popup touch-scroll">
    <div class="popup-header">
      <h3>{{  featureData.segmentname || "取水口详细信息"}}</h3>
      <!-- <div class="water-icon">
        <i class="el-icon-water-cup"></i>
      </div> -->
    </div>
    
    <div class="popup-body">

      <div class="base-info-box">
        <div class="base-info-title">
          <div class="header-title">基本信息</div>
        </div>
        <div class="base-info-grid">
          <!-- <div class="base-info-item">
            <span class="base-info-label">取水口名称</span>
            <span class="base-info-value">{{ featureData.segmentname }}</span>
          </div> -->
          <div class="base-info-item">
            <span class="base-info-label">取水口编码</span>
            <span class="base-info-value">{{ featureData.segmentdrinkcode }}</span>
          </div>
          <div class="base-info-item">
            <span class="base-info-label">取水口类型</span>
            <span class="base-info-value segmentcategory"  :class="getSegmentTypeClass(featureData.segmentcategory)" >{{ getSegmentTypeName(featureData.segmentcategory) }}</span>
          </div>
        </div>
      </div>

      <div class="base-info-box">
        <div class="base-info-title">
          <div class="header-title">水源地信息</div>
        </div>
         <div class="base-info-item-line">
            <span class="base-info-label-line">水源地名称</span>
            <span class="base-info-value-line">{{ featureData.drinksourcename }}</span>
          </div>
          <div class="base-info-item-line margin-top-12">
            <span class="base-info-label-line">水源地简介</span>
            <span class="base-info-value-line">{{ featureData.introduction || '暂无简介' }}</span>
          </div>
      </div>
      
      <div class="info-section">
        <h4 class="section-title">保护区信息</h4>
        <div class="protection-levels">
          <div class="level-card primary">
            <div class="level-header">
              <span class="level-name">一级保护区</span>
              <span class="level-area">{{ featureData.firstprotectarea || '未知' }} km²</span>
            </div>
            <div class="level-description">{{ featureData.primarydescribe || '暂无描述' }}</div>
          </div>
          
          <div class="level-card secondary">
            <div class="level-header">
              <span class="level-name">二级保护区</span>
              <span class="level-area">{{ featureData.secondarydescribe || '未知' }} km²</span>
            </div>
            <div class="level-description">{{ featureData.secondarydescribe || '暂无描述' }}</div>
          </div>
          
          <div class="level-card quasi">
            <div class="level-header">
              <span class="level-name">准保护区</span>
              <span class="level-area">{{ featureData.quasiprotectarea || '未知' }} km²</span>
            </div>
            <div class="level-description">{{ featureData.quasidescribe || '暂无描述' }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
// 定义 props
const props = defineProps({
  featureData: {
    type: Object,
    default: () => ({})
  },
  featureId: {
    type: String,
    default: ''
  }
});

// 取水口类型映射
const segmentcategoryMap = {
  '1': '河流',
  '2': '湖库',
  '3': '地下水'
};

// 获取取水口类型名称
const getSegmentTypeName = (type) => {
  return segmentcategoryMap[type] || '未知';
};

// 获取取水口类型样式类
const getSegmentTypeClass = (type) => {
  const classMap = {
    '1': 'river',
    '2': 'lake',
    '3': 'groundwater'
  };
  return classMap[type] || 'unknown';
};

// 在 mounted 钩子中打印数据
import { onMounted } from 'vue';
onMounted(() => {
  console.log(props.featureData);
});
</script>

<style scoped>
.qushuikou-popup {
  max-width: 100%;
  width: 100%;
  margin: 0;
  border-radius: 0;
  padding: 0;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* 设置容器高度为视口高度 */
  height: 80vh;
  /* 确保在不同设备上正常显示 */
  position: fixed;
}


/* 触摸滚动通用样式 */
.touch-scroll {
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* 隐藏滚动条但保持功能 */
.touch-scroll::-webkit-scrollbar {
  display: none;
}


.popup-header {
  font-size: 18px;
  font-weight: 600;
  padding: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popup-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.water-icon {
  background: rgba(255, 255, 255, 0.2);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.popup-body {
padding: 15px;
/* 启用垂直滚动 */
  overflow-y: auto;
  /* 占满剩余空间 */
  flex: 1;
  /* 优化iOS滚动体验 */
  -webkit-overflow-scrolling: touch;
  /* 隐藏滚动条 */
  -ms-overflow-style: none;
  scrollbar-width: none;
}


/* 隐藏滚动条但保持功能 */
.body::-webkit-scrollbar {
  display: none;
}



/* 基础信息卡片样式 */
.base-info-box {
  background: white;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  margin-bottom: 20px;
  border: 1px solid #f0f0f0;
  transition: all 0.3s ease;
}

.base-info-box:hover {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

/* 标题区域样式 */
.base-info-title {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
  margin-bottom: 12px;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
  color: #2c3e50;
}

.sample-time {
  font-size: 14px;
  color: #7f8c8d;
  background: #ecf0f1;
  padding: 4px 12px;
  border-radius: 20px;
}

/* 信息网格布局 */
.base-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

/* 信息项样式 */
.base-info-item {
  display: flex;
  justify-content: space-between;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-radius: 12px;
  transition: all 0.3s ease;
}

.base-info-item:hover {
  background: linear-gradient(135deg, #f0f2f5, #dde1e6);
}

/* 标签和值的样式 */
.base-info-label {
  font-weight: 500;
  color: #7f8c8d;
  font-size: 12px;
}

.base-info-value {
  margin-top: 4px;
  font-weight: 700;
  color: #2c3e50;
  font-size: 14px;
  border-radius: 12px;
}

/* 水质级别特殊样式 */
.base-info-value.segmentcategory {
  padding: 6px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
}


.margin-top-12 {
  margin-top: 18px;
}

.base-info-item-line {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-radius: 12px;
  transition: all 0.3s ease;
}
.base-info-item-line:hover {
  background: linear-gradient(135deg, #f0f2f5, #dde1e6);
}

/* 标签和值的样式 */
.base-info-label-line {
  font-weight: 500;
  color: #7f8c8d;
  font-size: 12px;
}

.base-info-value-line {
  margin-left: 12px;
  font-weight: 700;
  color: #2c3e50;
  font-size: 14px;
}

.info-section {
  margin-bottom: 24px;
}

.info-section:last-child {
  margin-bottom: 0;
}

.section-title {
  font-size: 16px;
  color: #1a73e8;
  margin: 0 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid #e3f2fd;
  font-weight: 500;
}


.base-info-value.river {
  background: linear-gradient(90deg, #42a5f5, #1e88e5);
  color: white;
}

.base-info-value.lake {
  background: linear-gradient(90deg, #26c6da, #00acc1);
  color: white;
}

.base-info-value.groundwater {
  background: linear-gradient(90deg, #66bb6a, #43a047);
  color: white;
}

.base-info-value.unknown {
  background: #e0e0e0;
  color: #616161;
}

.protection-levels {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.level-card {
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s, box-shadow 0.2s;
}

.level-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.level-card.primary {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border-left: 4px solid #1a73e8;
}

.level-card.secondary {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  border-left: 4px solid #43a047;
}

.level-card.quasi {
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  border-left: 4px solid #fb8c00;
}

.level-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.level-name {
  font-weight: 600;
  color: #1a237e;
}

.level-area {
  background: rgba(255, 255, 255, 0.7);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.level-description {
  font-size: 13px;
  color: #455a64;
  line-height: 1.5;
}

/* 滚动条样式 */
.popup-body::-webkit-scrollbar {
  width: 6px;
}

.popup-body::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.popup-body::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 10px;
}

.popup-body::-webkit-scrollbar-thumb:hover {
  background: #a1a1a1;
}

/* 响应式设计 */
@media (max-width: 600px) {

     /* 进一步优化移动设备上的滚动体验 */
  .popup-body {
    padding: 12px;
    -webkit-overflow-scrolling: touch;
  }
  
  .info-grid {
    grid-template-columns: 1fr;
  }
  
  .info-item.full-width {
    grid-column: span 1;
  }
}


/* 为触摸设备添加特殊样式 */
@media (hover: none) and (pointer: coarse) {
  
  /* 优化滚动效果 */
  .popup-body {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
}
</style>